package com.marvels.loanapply.loan.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.marvels.common.dto.MarvelsResultDTO;
import com.marvels.common.exception.MarvelsBusinessException;
import com.marvels.common.exception.MarvelsErrorCode;
import com.marvels.common.utils.MarvelsLogUtil;
import com.marvels.loanapply.loan.dto.StateDetailedDTO;
import com.marvels.loanapply.loan.service.IStateDetailedService;

@RestController
@RequestMapping("/loanApply/loan/api")
public class StateDetailedApiController {
	@Autowired
	public IStateDetailedService stateDetailedService;
	
	@RequestMapping("querysdetail")
	public String queryStateDetailedByNodeCode(@RequestBody String nodeCode) {
		try {
			StateDetailedDTO result = stateDetailedService.findStateDetailedByNodeCode(nodeCode);
			return result==null?null:result.getStateId();
		}catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error("查询失败",e);
			return null;
		}catch(Exception e){
			MarvelsLogUtil.getInstance().error("查询错误",e);
			return null;
		}
	}
	
	
	
	@RequestMapping("queryStateDetailed")
	public List<StateDetailedDTO> queryStateDetailed(@RequestBody StateDetailedDTO dto) {
		try {
			List<StateDetailedDTO> list = stateDetailedService.findStateDetailed(dto);
			return list;
		}catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error("查询失败",e);
			return null;
		}catch(Exception e){
			MarvelsLogUtil.getInstance().error("查询错误",e);
			return null;
		}
	}
}
